package com.wva.user.utils;

import com.wva.user.constant.LoginConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;

/**
 * @Author: hong
 * @Date: 2025/2/21 01:38:39
 */
@Component
public class LoginUtils {
    @Autowired
    JwtUtils jwtUtils;

    public String getTokenByUserId(Long userId) {
        HashMap<String, Object> claims = new HashMap<>();
        claims.put("userId", userId);
        String jwt = jwtUtils.createJWT(claims, TimeUnit.MINUTES.toMillis(LoginConst.TOKEN_TIMEOUT));
        return jwt;
    }
}
